set(CMAKE_VERBOSE_MAKEFILE yes)

find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(SWS REQUIRED libswscale)
pkg_check_modules(SWR REQUIRED libswresample)

include_directories(
        ${AVCODEC_INCLUDE_DIRS}
        ${AVFORMAT_INCLUDE_DIRS}
        ${AVUTIL_INCLUDE_DIRS}
        ${SWS_INCLUDE_DIRS}
        ${SWR_INCLUDE_DIRS}
        ${OPUS_INCLUDE_DIRS}
        stage/include/)

link_directories(
    ${VPX_LIBRARY_DIRS}
    ${AVCODEC_LIBRARY_DIRS}
    ${AVFORMAT_LIBRARY_DIRS}
    ${AVUTIL_LIBRARY_DIRS}
    ${SWS_LIBRARY_DIRS}
    ${SWR_LIBRARY_DIRS}
    ${LOG4CPLUS_LIBRARY_DIRS}
    ${OPUS_LIBRARY_DIRS}
    ${X264_LIBRARY_DIRS}
    ${CMAKE_SOURCE_DIR}/stage/lib/
)

message("mixer: AVCODEC_LDFLAGS=${AVCODEC_LDFLAGS}")
message("mixer: AVCODEC_STATIC_LIBRARIES=${AVCODEC_STATIC_LIBRARIES}")
message("mixer: AVCODEC_STATIC_OTHER_LDFLAGS=${AVCODEC_STATIC_OTHER_LDFLAGS}")

if (APPLE)
    set_target_properties(tlv PROPERTIES LINK_FLAGS "-framework CoreFoundation \
    -framework CoreServices -framework QuartzCore -framework VideoDecodeAcceleration")
endif (APPLE)

add_executable(mixer
        main_mixer.cpp
        mixer.hpp
        input.hpp
        output.hpp
        )

target_link_libraries(mixer
        ${OPUS_STATIC_LIBRARIES}
        ${AVCODEC_STATIC_LIBRARIES}
        ${AVFORMAT_STATIC_LIBRARIES}
        ${AVUTIL_STATIC_LIBRARIES}
        ${SWR_STATIC_LIBRARIES}
#        "-L${CMAKE_SOURCE_DIR}/third/webrtc/lib/ -laudio_recveq -lpthread"
        )

add_executable(comp
        main_comp.cpp
        input.hpp
        compare.hpp
        dtw.hpp)

target_link_libraries(comp
        ${OPUS_STATIC_LIBRARIES}
        ${AVCODEC_STATIC_LIBRARIES}
        ${AVFORMAT_STATIC_LIBRARIES}
        ${AVUTIL_STATIC_LIBRARIES}
        ${SWR_STATIC_LIBRARIES}
        #        "-L${CMAKE_SOURCE_DIR}/third/webrtc/lib/ -laudio_recveq -lpthread"
        )

install(TARGETS mixer DESTINATION bin)
#add_executable(test_nack ../../../src/nack_handler.cpp ../../../src/nack_handler.hpp)